"""finance_c2c URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.documentation import include_docs_urls
from rest_framework.schemas import get_schema_view

schema_view = get_schema_view(title='Pastebin API')

router = routers.DefaultRouter()
self_info_router = routers.DefaultRouter()
util_router = routers.DefaultRouter()
czb_router = routers.DefaultRouter()
gas_router = routers.DefaultRouter()
zx_router = routers.DefaultRouter()

finance_router = routers.DefaultRouter()
admin_router = routers.DefaultRouter()
coffee_router = routers.DefaultRouter()
coffee_router_v2 = routers.DefaultRouter()
wchat_mini_router = routers.DefaultRouter()
wchat_mini_router_v2 = routers.DefaultRouter()
yl_router = routers.DefaultRouter()

OutApiBaseUrl = 'v1/api/'
#
from apps.product.class_views import ProductViewSet
from apps.sales_man.class_views import VisitApplicantViewSet
from apps.product.class_views import ProductProvinceViewSet  # 获取省份列表
from apps.product.class_views import ProductCityViewSet  # 获取省份城市列表
# from rest_framework_jwt.views import obtain_jwt_token
from apps.user_operation.views import RegisterViewSet, LoginRegisterViewSet
from apps.user_operation.views import ClickProductViewSet, TelCodeViewSet, SelfInfoViewSet, TeamViewSet, \
    LeaderViewSet, BankCardNoViewSet, UpdateTelViewSet, UfViewSet, LevelUpProgress, NameViewSet, MenusViewSet, \
    ObtainJSONWebToken, WXLoginRegisterViewSet, NickNameViewSet, PopularsViewSet
# 我买网电商
from apps.supply_order import views as supply_views
from core.tools.c_views import ProvinceViewSet, CityViewSet, CountyViewSet, ShortMsgViewSet, BankCodeViewSet
from apps.czb import views as czb_views
from apps.czb import api
from core.zhongxin import views as zx_views
from apps.coffee import views as coffee_views
from core.wchat.views import H5WxPayAPIView, JsWxPayAPIView
from core.wchat.wchat_mini import WeChatOrderViewSet
from core.wchat import wchat_mini_v2
from core.yl import views as YlViews
from core.wchat import views as wechat_views
from apps.coffee_admin.urls import coffeeAdmin
from core.tl.views import AllinPayViewSets
# 咖啡
coffee_router.register("share", coffee_views.UserShareViewSets, base_name="UserShare")
coffee_router.register("h5Active", coffee_views.H5ActiveViewSets, base_name="h5Active")
coffee_router.register("shopList", coffee_views.ShopInfoViewSets, base_name="shopList")
coffee_router.register("coupon-by-mobile", coffee_views.MobileGetViewSets, base_name="couponByMobile")
coffee_router.register("ReceiveShared", coffee_views.ReceiveSharedViewSets, base_name="ReceiveShared")
coffee_router.register('coupon', coffee_views.CouponViewSets, base_name="coupon")
coffee_router.register('banner', coffee_views.BannerViewSets, base_name="banner")
coffee_router.register('trade', coffee_views.TradeViewSets, base_name="trade")
coffee_router.register('client', coffee_views.ClientViewSets, base_name="client")  # 咖啡机列表
coffee_router.register('ordersCoupon', coffee_views.OrdersCouponViewSets, base_name="ordersCoupon")  # 提交订单时优惠券展示
coffee_router.register('ChannelCoupon', coffee_views.ChannelCouponViewSets, base_name="ChannelCoupon")  # 查看券数量
coffee_router.register('useRecord', coffee_views.UseViewSets, base_name="use_record")
coffee_router.register('giveRecord', coffee_views.GiveRecordViewSets, base_name="give_record")
coffee_router.register('orders', coffee_views.Orders, base_name="coffeeOrders")
coffee_router.register('ordersUpdate', coffee_views.OrderUpdateViewSets, base_name="coffeeOrderUpdate") # 换免费券
coffee_router.register('giveByMobile', coffee_views.GiveByMobile, base_name="giveByMobile")
coffee_router.register('systemReceive', coffee_views.SystemReceiveViewSets, base_name="systemReceive")  # 扫系统赠送码
coffee_router.register('coffeeInfo', coffee_views.GoodsViewSets, base_name="coffeeGoodsInfo")  # 咖啡商品详情
coffee_router.register('ScanCodeResult', coffee_views.ScanCodeResult, base_name="ScanCodeResult")  # 扫码结果
coffee_router.register('coffeePrice', coffee_views.CoffeePriceViewSets, base_name="coffeePrice")  # 咖啡价格(减钱后的价格)
coffee_router.register('payType', coffee_views.PaymentTypeViewSets, base_name="payType")  # 支付优惠默认选择
coffee_router.register('reduceMoneyList', coffee_views.ReduceMoneyViewSets, base_name="reduceMoneyList")  #
coffee_router.register('groupQrCode', coffee_views.GroupQrCodeViewSets, base_name="groupQrCode")  # 群聊二维码
coffee_router.register('receive', coffee_views.ReceiveViewSets, base_name="receive")  # 接收有优惠券
coffee_router.register('giveRecordUrl', coffee_views.GiveRecordUrl, base_name="giveRecordUrl")
coffee_router.register('h5CommitOrder', coffee_views.H5CommitOrderViewSets, base_name="H5CommitOrder")  # h5提交返回小程序码
coffee_router.register('UserBagRecord', coffee_views.UserBagRecordViewSets, base_name="UserBagRecord")  # 领取记录
coffee_router.register('InvoiceRecord', coffee_views.InvoiceViewSets, base_name="InvoiceViewSets")  #
coffee_router.register('Invoice', coffee_views.InvoiceInfoViewSets, base_name="InvoiceInfoViewSets")  # 发票信息
coffee_router.register('groupQRCode', coffee_views.GroupClientViewSets, base_name="groupQRCode")  # 群聊
coffee_router.register('clientCities', coffee_views.CitiesViewSets, base_name="clientCities")  # 机器位置
coffee_router.register('member', coffee_views.MemberViewSets, base_name="clientCities")  # 会员
coffee_router.register('ShowMember', coffee_views.ObtainDiscountViewSets, base_name="ObtainDiscount")  # 领取会员
coffee_router.register('FriendShare', coffee_views.FriendShareViewSets, base_name="FriendShare")  # get 好友分享列表 post 领取券
coffee_router.register('PayTitle', coffee_views.PayTitleViewSets, base_name="PayTitle")  # 优惠显示
# coffee_router.register('ShowMember', coffee_views.ShowObtainDiscountViewSets, base_name="ShowObtainDiscount")  # 显示

# 随机券
coffee_router.register("RandomCoupon", coffee_views.RandomCouponViewSets, base_name="RandomCoupon")  # 随机券记录
coffee_router.register("SysRandomCoupon", coffee_views.SystemCodeRandomViewSets,
                       base_name="SysRandomCoupon")  # 系统随机券记录

coffee_router.register("SelfInfo", coffee_views.SelfInfoViewSet, base_name="SelfInfo")  # 个人信息
coffee_router.register("ReduceActive", coffee_views.ReduceMoneyEveryDayActiveViewSets, base_name="ReduceActive")  # 个人信息
# -------卡包-----------
coffee_router.register('CardBag', coffee_views.CardBagViewSets, base_name="CardBag")  # 卡包列表
coffee_router.register('CardBagOrders', coffee_views.CardBagOrdersViewSets, base_name="CardBagOrders")  # 订单
# coffee_router.register('CardBagOrders', coffee_views.CardBagOrdersViewSets, base_name="CardBagOrders")  # v2订单
coffee_router.register('userCardBag', coffee_views.UserCardBagViewSets, base_name="userCardBag")  # 用户卡包列表
coffee_router.register('UserFoldCardBag', coffee_views.UserFoldCardBagViewSets, base_name="UserFoldCardBag")  # 折叠卡包
# ------银行兑换卡券----
coffee_router.register('BankExchangeCode', coffee_views.BankExchangeCodeViewSets, base_name="BankExchangeCode")  # 银行兑换券
coffee_router.register('AllinPay', AllinPayViewSets, base_name="AllinPay")  # 银行兑换券

# 中信银行
zx_router.register(r"pay", zx_views.PayViewSet, base_name="zx_pay")  # 获取连接

# 车主邦
czb_router.register(r"gas_station", czb_views.QueryPriceByPhone, base_name="QueryPriceByPhone")  # 用户获取加油站信息
czb_router.register(r"api-channel", czb_views.ApiDetailViewSet, base_name="api-channel")  # 渠道详情
czb_router.register(r"orders", czb_views.OrdersViewSet, base_name="OrdersViewSet")  # 订单创建/查询
czb_router.register(r"equity", czb_views.EquityViewSet, base_name="EquityViewSet")  # 提交权益订单
czb_router.register(r"price_list", czb_views.ExpiryDatePriceSerializersViewSet, base_name="price_list")  # 购买权益价格列表
czb_router.register(r"depreciateAmount", czb_views.DepreciateAmountViewSet, base_name="depreciate_amount")  # 购买权益价格列表
czb_router.register(r"receipt-ticket", czb_views.ReceiptTicketViewSet, base_name="receipt-ticket")  # 开票信息
czb_router.register(r"order-ticket", czb_views.OrderTicketViewSet, base_name="order-ticket")  # 订单开票
czb_router.register(r"gas-follow", czb_views.GasFollowViewSet, base_name="gas-follow")  # 加油站关注

# 个人信息
self_info_router.register(r'team', TeamViewSet, base_name='team')  # 团队
self_info_router.register(r'populars', PopularsViewSet, base_name='populars')  # 推广图
self_info_router.register(r'nick_name', NickNameViewSet, base_name='nick_name')  # 用户名字
self_info_router.register(r'my_info', SelfInfoViewSet, base_name="my-info")  # 个人信息
self_info_router.register(r'band-leader', LeaderViewSet, base_name="band-leader")  # 绑定上级
self_info_router.register(r'bank-card-no', BankCardNoViewSet, base_name="bank-card-no")  # 绑定更换银行卡
self_info_router.register(r'update-tel', UpdateTelViewSet, base_name="update-tel")  # 更换手机号
self_info_router.register(r'username', NameViewSet, base_name="username")  # 更新真实信息
self_info_router.register(r'ufu', UfViewSet, base_name="ufu")  # 推荐优秀服务商
self_info_router.register(r'level_up_progress', LevelUpProgress, base_name="level_up_progress")  # 会员升级进度

# 城市地区获取
util_router.register(r'province', ProvinceViewSet, base_name="province")  # 省份
util_router.register(r'city', CityViewSet, base_name="city")  # 城市
util_router.register(r'county', CountyViewSet, base_name="county")  # 县城
# 获取验证码
util_router.register(r"shot-msg", ShortMsgViewSet, base_name="shortMsg")  # 获取验证码
util_router.register(r"bank", BankCodeViewSet, base_name="bank_code")  # 银行对应的银行id

# 商城
router.register(r'goods', supply_views.GoodsViewSet, base_name="goods")  # 商品列表
router.register(r'coffee_banner', supply_views.BannerViewSet, base_name="coffee_banner")  # banner
router.register(r'collect', supply_views.CollectViewSet, base_name="collect")  # 收藏
router.register(r'receiver', supply_views.ReceiverPlaceViewSet, base_name="receiver")  # 发货地址
router.register(r'active_time', supply_views.ActiveTime, base_name="active_time")  # 首页抢购
router.register(r'index_pre', supply_views.IndexPreViews, base_name="index_pre")  # 首页专区
router.register(r'inventory', supply_views.InventoryViewSet, base_name="Inventory")  # 查看库存
router.register(r'orders', supply_views.AllOrderViewSet, base_name="orders")  # 订单列表
router.register(r'base_order', supply_views.BaseOrderViewSet, base_name="base_order")  # 用于查看订单状态
router.register(r'buy_now', supply_views.BuyNowViewSet, base_name="buy_now")  # 立刻购买
# router.register(r'yf', supply_views.YFViewSet, base_name="yf")  # 运费
router.register(r'logistics', supply_views.LogisticsViewSet, base_name="logistics")  # 物流信息查询
router.register(r'area-vaild', supply_views.AreaViewSet, base_name="area-vaild")  # 区域配送是否有效
router.register(r'cart-item', supply_views.CartItemViewSet, base_name="CartItem")  # 购物车
router.register(r'income', supply_views.IncomeViewSet, base_name="income")  # 收益
router.register(r'transfer-record', supply_views.TransferRecord, base_name="transfer-record")  # 提现记录
router.register(r'category', supply_views.CategoryViewSet, base_name="category")  # 商品分类
router.register(r'child-order', supply_views.ChildOrderViewSet, base_name="child-order")  # 子订单列表
# router.register(r'gg-card', supply_views.GGCardViewSets, base_name="gg-card")  # ggcard

# 后台
router.register(r'post-company', supply_views.PostCompanyViewSet, base_name="post-company")  # 物流公司
admin_router.register(r'refund', supply_views.Refund, base_name="refund")  # 申请退款后台
admin_router.register(r'send', supply_views.PostOrder, base_name="send")  # 物流订单信息
admin_router.register(r'post_goods', supply_views.PostGoods, base_name="post_goods")  # 发货
admin_router.register(r'menus', MenusViewSet, base_name="menus")  # 菜单
admin_router.register(r'export', czb_views.ExportOrders, base_name="export")  # 导出订单
admin_router.register(r'czb-orders', czb_views.AdminOrders, base_name="czb-orders")  # 后台结算单
admin_router.register(r'czb-orders-total', czb_views.AdminOrdersTotal, base_name="czb-orders-total")  # 后台结算统计
admin_router.register(r'channel-list', czb_views.ChannelViewSet, base_name="channel-list")  # 渠道列表

finance_router.register(r'products', ProductViewSet, base_name="products")  # 开发者列表在使用
finance_router.register(r'tel-code', TelCodeViewSet, base_name="tel-code")
finance_router.register(r'click-product', ClickProductViewSet, base_name="ClickProductViewSet")
finance_router.register(r'product-province', ProductProvinceViewSet, base_name="ProductProvinceViewSet")
finance_router.register(r'product-city', ProductCityViewSet, base_name="ProductCityViewSet")
finance_router.register(r'visit-apply', VisitApplicantViewSet, base_name="VisitApplicantViewSet")  # 思兮api
finance_router.register(r'register', RegisterViewSet, base_name="RegisterViewSet")  # 用户输入手机姓名

# 加油往外接
gas_router.register(r'initGas', api.InitGasViewSet, base_name="InitGasViewSet")
gas_router.register(r'queryGasByPhone', api.QueryGasByPhoneViewSet, base_name="QueryGasByPhone")
gas_router.register(r'generateOrders', api.GenerateOrdersViewSet, base_name="GenerateOrders")
gas_router.register(r'queryOrders', api.QueryOrdersViewSet, base_name="queryOrders")
gas_router.register(r'cancelOrders', api.CancelOrdersViewSet, base_name="cancelOrders")
gas_router.register(r'payCallback', api.PayCallbackViewSet, base_name="payCallback")
gas_router.register(r'refund', api.RefundViewSet, base_name="refund")
gas_router.register(r'equity', api.EquityViewSet, base_name="equity")  # 购买权益
gas_router.register(r'depreciateAmount', api.DepreciateAmountViewSet, base_name="depreciate_amount")  # 购买权益
gas_router.register(r'queryInvoice', api.QueryInvoice, base_name="queryInvoice")  # 查询开票接口
gas_router.register(r'insertInvoice', api.Invoice, base_name="insertInvoice")  # 开票接口

# 小程序
wchat_mini_router.register('weChatOrder', WeChatOrderViewSet, base_name="WeChatOrder")  # JSAPI统一下单
wchat_mini_router.register('jsWxPay', JsWxPayAPIView, base_name="jsWxPay")  # 公众号
wchat_mini_router.register('h5WxPay', H5WxPayAPIView, base_name="h5WxPay")  # h5统一下单

wchat_mini_router_v2.register('weChatOrder', wchat_mini_v2.WeChatOrderViewSet, base_name="WeChatOrder")  # JSAPI统一下单

# 银联支付H5
yl_router.register('wxPay', YlViews.YlWxPayAPIView, base_name="YlWxPay")  # 银联公众号pay

# v2

coffee_router_v2.register('UserBagRecord', coffee_views.V2UserBagRecordViewSets, base_name="V2UserBagRecord")  # 领取记录
coffee_router_v2.register('giveRecordUrl', coffee_views.GiveRecordUrlV2, base_name="giveRecordUrlV2")
coffee_router_v2.register('h5CommitOrder', coffee_views.V2H5CommitOrderViewSets,
                          base_name="V2H5CommitOrderViewSets")  # h5提交返回小程序码
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
                  url(r'^coffeeAdmin/', include(coffeeAdmin.urls)),  # coffee admin
                  url(r'^(?P<file_name>\w+.txt)$', wechat_views.wx_file, name='wx_file'),  # 微信文件
                  url(r'^mp/', include(wchat_mini_router.urls)),
                  url(r'^v2/mp/', include(wchat_mini_router_v2.urls)),

                  url(r'^mp/', include('core.wchat.urls', namespace="wx")),
                  url(r'^v2/mp/', include('core.wchat.urls_v2', namespace="wx_v2")),
                  url(r'^v2/coffee/api/', include(coffee_router_v2.urls)),

                  url(r'^c2c/admin/', include(admin.site.urls)),
                  url(r'^callback/', include('apps.test_callback.urls', namespace="test_callback")),
                  url(r'^c2c/', include('apps.order.urls', namespace="order")),
                  url(r'^c2c/operation/', include('apps.user_operation.urls', namespace="user_operation")),
                  url(r'^c2c/', include('apps.product.urls', namespace="product")),
                  url(r'^c2c/', include('apps.sales_man.urls', namespace="sales_man")),
                  url(r'^c2c/', include('apps.popular_img.urls', namespace="popular_img")),
                  url(r'^c2c/', include('apps.c2cAdmin.urls', namespace="c2cAdmin")),
                  url(r'^', include('apps.my_admin.urls', namespace="my_admin")),
                  url(r'^c2c/tools/', include('core.tools.urls', namespace="tools")),
                  url(r'^yl/', include(yl_router.urls)),
                  url(r'^docs/', include_docs_urls(title="生成文档")),
                  url(r'^api-auth/', include('rest_framework.urls')),
                  url(r'^api/', include(finance_router.urls)),
                  url(r'^coffee/api/', include(coffee_router.urls)),
                  url(r'^coffee/api/', include('apps.coffee.urls', namespace="coffee")),
                  url(r'^czb/api/', include(czb_router.urls)),
                  url(r'^czb/api/', include('apps.czb.urls', namespace="czb_api")),
                  url(r'^selfInfo/api/', include(self_info_router.urls)),  # 个人信息api
                  url(r'^util/api/', include(util_router.urls)),  # 公用api
                  url(r'^citic/', include(zx_router.urls)),  # 中信银行
                  url(r'^citic/', include('core.zhongxin.urls', namespace="citic")),  # 中信银行
                  url(r'^shop/api/', include(router.urls)),
                  url(r'^shop/admin/api/', include(admin_router.urls)),
                  url(r'^shop/api/', include('apps.supply_order.urls', namespace="supply_order")),
                  url(r'^shop/api/', include('core.tl.urls', namespace="tl")),
                  url(r'^yl/', include('core.yl.urls', namespace="yl_pay")),
                  url(r'^ali/', include('core.alipay.urls', namespace="alipay")),
                  # url(r'^selfInfo/api/', include('apps.user_operation.c_urls', namespace="selfInfo")),
                  url(r'^jwt-login/$', LoginRegisterViewSet.as_view()),  # 手机号验证码登录
                  url('^schema/$', schema_view),
                  url(r'^admin-login/', ObtainJSONWebToken.as_view()),  # 后台用户登录
                  url(r'^wx-login/', WXLoginRegisterViewSet.as_view()),  # 微信登录
                  url(r'^jwt-token/', obtain_jwt_token),  # 原始登录
                  url(r'^' + OutApiBaseUrl, include(gas_router.urls)),
                  url(r'^' + OutApiBaseUrl, include('apps.user_operation.APIurls', namespace="v1api")),
              ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
